package org.adorsys.aderp.jpa.api.bk;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * Used to discover the business key of an entity.
 * 
 * In oder to allow for configuration by exception, the
 * application will rely on the field keyXXX as a business
 * key if this annotation is not found.
 * 
 * This interface shall be implemented by entity jpa which have a business key. 
 * In this framework, we use the business key to track the record. This has 
 * priority on the technical database id. If while saving or updating an entity 
 * jpa, if there is one in the data base with the same business key, we will consider
 * an update. If there is no object with the same business key in the database,
 * we will consider the following operation a create and set the id and version of
 * this bean to null. This last case assumes that primary key and business key
 * are different fields.
 * 
 * In general, the primary key will be the field named id of type and the business key
 * will have any meaning as desired by the business logic.
 * 
 * For know, we want those business keys to be string.
 * 
 * With this concept, we can implement powerful data synchronization concepts,
 * without having to rely on database id.
 * 
 * @author francis
 *
 */
@Documented
@Target({ElementType.FIELD})
@Retention(RUNTIME)
public @interface BusinessKey {

}
